package com.wtz.temptest;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Date: 2020/9/14
 * Company: www.dtstack.com
 *
 * @author tiezhu
 */
public class TempPattern {
    private static final Pattern TEST_PATTERN = Pattern.compile("(?i)((@*\\S+\\.)*\\S+)\\s+(.+?)\\s+AS\\s+(\\w+)(\\s+NOT\\s+NULL)?$");
    private static final Pattern DEMO_PATTERN = Pattern.compile("(?i)((@*\\S+\\.)*\\S+)\\s+(.+?)\\s+AS\\s+(\\w+)(\\s+NOT\\s+NULL)?$");

    private static final Pattern DEM_PATTERN_TWO = Pattern.compile("(\\s+NOT\\s+NULL)?$");
    public static void main(String[] args) {
        String testData = "TO_TIMESTAMP(FROM_UNIXTIME(start_time, 'yyyy-MM-dd hh:mm:ss')) AS ts";
        Matcher matcher = DEMO_PATTERN.matcher(testData);
        if (matcher.find()) {
            System.out.println(matcher.group(1));
        }
    }
}
